//
// Created by Administrator on 2023/8/6.
//
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class Solution {
public:
    int splitNum(int num) {
        vector<int> v;
        while (num > 0) {
            if (num % 10 == 0)
                num /= 10;
            else {
                v.push_back(num % 10);
                num /= 10;
            }
        }
        sort(v.begin(), v.end());
        int a = 0, b = 0;
        // 轮流塞进 a b
        for (int i = 0; i < v.size(); i++) {
            if (i % 2 == 0)
                a = a * 10 + v[i];
            else
                b = b * 10 + v[i];
        }
        return a + b;
    }

};

int main() {
    Solution s;
    cout << s.splitNum(123456789) << endl;
    cout << s.splitNum(4325) << endl;
    cout << s.splitNum(687) << endl;
    return 0;
}